<template>
  <div>
    <el-card>
      <div class="artist-list">
        <div class="radio-list">
          <span class="w-60">语种：</span>
          <el-radio-group v-model="queryInfo.area">
            <el-radio
              :label="ar.id"
              v-for="ar in artistData.area"
              :key="ar.id"
              >{{ ar.value }}</el-radio
            >
          </el-radio-group>
        </div>
        <div class="radio-list">
          <span class="w-60">分类：</span>
          <el-radio-group v-model="queryInfo.type">
            <el-radio
              :label="tp.id"
              v-for="tp in artistData.type"
              :key="tp.id"
              >{{ tp.value }}</el-radio
            >
          </el-radio-group>
        </div>
        <div class="radio-list">
          <span class="w-60">筛选：</span>
          <el-radio-group v-model="queryInfo.initial">
            <el-radio
              :label="it.id"
              v-for="it in artistData.initial"
              :key="it.id"
              >{{ it.value }}</el-radio
            >
          </el-radio-group>
        </div>
      </div>
      <ImgList
      @clickImg="toArtistDetail"
      :list="artistList"
      type="artist"
      :isLoading="isLoading"
      >
      </ImgList>
    </el-card>
  </div>
</template>

<script>
const artistData = require("@/assets/json/artistData.json");
import { getArtistList } from "@/api/request";
import ImgList from "@/components/list/ImgList.vue"
export default {
  components:{
    ImgList
  },
  data() {
    return {
      queryInfo: {
        limit : 100,
        //查询信息
        area: -1,
        offset: 0,
        type: -1,
        initial: '-1'
      },
      artistData, // 列表项
      artistList: [], // 歌手列表
      isLoading: false, // 正在获取歌手列表
    }
  },
  created() {
    this.getArtistList();
  },
  watch: {
    queryInfo:{
      deep:true,
      handler(){
        this.getArtistList();
      }
    }
  },
  methods: {
    async getArtistList() {
      this.isLoading = true;
      const {data:res} = await getArtistList(this.queryInfo)
      if (res.code !== 200) return this.$message.error('获取失败')
      console.log(res);
      this.artistList = res.artists;
      this.isLoading = false ;
    },
    toArtistDetail(id){
      if(typeof id === 'number'){
        this.$router.push("/artistdetail/" + id)
      }
    },
  },
};
</script>

<style lang="less" scoped>
.radio-list {
  display: flex;
  flex-wrap: wrap;
  line-height: 20px;
  margin-top: 10px;
  span {
    height: 30px;
    line-height: 30px;
  }
  .el-radio-group {
    width: 80%;
    .el-radio {
      width: 60px;
      height: 30px;
      line-height: 30px;
    }
  }
}
/deep/.el-radio__input{
    display: none;
}
</style>